package net.huashitong.supervision.gongjian.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.gongjian.entity.project.ZhaoShangProjectEntity;
import net.huashitong.supervision.gongjian.filter.ZhaoShangProjectFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ZhaoShangProjectDao extends StringDao<ZhaoShangProjectEntity> {

    public List<ZhaoShangProjectEntity> getList(ZhaoShangProjectFilter filter)
    {
        GenericQuery query =createQuery("obj");
        return query.listResult(filter);
    }

    public List<ZhaoShangProjectEntity> getListNoPage(ZhaoShangProjectFilter filter)
    {
        GenericQuery query =createQuery("obj");
        return query.listResult();
    }


    public List<ZhaoShangProjectEntity> getListForOwn(ZhaoShangProjectFilter filter)
    {
//        GenericQuery query =createQuery("obj");
        String hql = "select z " +
                "     from  ZhaoShangProjectEntity as z ,GjDeptProject as g " +
                "      where z.sysId=g.projectId ";
        GenericQuery query =create(hql);
        if(StringUtils.isNotBlank(filter.getDeptId()))
        {

            query.append(" and g.deptId=:deptId").setParam("deptId",filter.getDeptId());
        }
        query.append(" and g.projectType=:projectType").setParam("projectType",filter.getProjectType());
        return query.listResult(filter);
    }
}
